﻿/// <reference path="../GeneratedArtifacts/viewModel.js" />

myapp.At14TrainsessionParticipantAddEdit.created = function (screen) {
    screen.AddToTraingroup = true;
};

myapp.At14TrainsessionParticipantAddEdit.beforeApplyChanges = function (screen) {
    if (screen.AddToTraingroup) {
        var newTraingroupMember = new myapp.trTraingroupStakeholder();

        //Set Stakeholder
        screen.trStakeholderTrainsession.getTbStakeholder().then(function (Stakeholder) {
            newTraingroupMember.setTbStakeholder(Stakeholder);
        });

        //Set AttandanceType
        screen.trStakeholderTrainsession.getAttendanceType().then(function (Attandance) {
            newTraingroupMember.setAttendanceType(Attandance);
        });

        //Set Traingroup
        screen.trStakeholderTrainsession.getTbTrainsession().then(function (Trainsession) {
                Trainsession.getTlTraingroup().then(function (Traingroup) {
                    newTraingroupMember.setTlTraingroup(Traingroup);
                });
        });
        
    }
};